package com.atguigu.eduservice.controller;
import com.atguigu.commonutils.Result;
import com.atguigu.eduservice.service.OssService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@RequestMapping("/update")
@RestController
@CrossOrigin //解决跨域的问题
public class OssController {

	@Resource
	private OssService ossService;

	@PostMapping

	public Result upload(MultipartFile imgFile) {

		String url = ossService.upload(imgFile);

		if (url != null) {
			return Result.ok().data("url", url);
		}
		return Result.error();
	}

}
